package data_structures_and_algorithms.tree.traverse;


import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

// https://leetcode.cn/problems/n-ary-tree-postorder-traversal/ 590、N叉树的后序遍历
public class _590_N_tree_postOrderTraversal {

    List<Integer> list = new LinkedList<>();
    public List<Integer> postorder(Node root) {
        postOrderCur(root);
        return list;
    }

    // 后序遍历
    public void postOrderCur(Node node){
        if (node == null)
            return;
        for (Node nodeTep: node.children) {
            postOrderCur(nodeTep);
        }

        list.add(node.val);
    }

    public void postOrderPost(Node nodeParam){
        if (nodeParam == null)
            return;
        Deque<Node> deque = new LinkedList<>();
        Node node = nodeParam;
        while (node != null || !deque.isEmpty()){
            while (node != null){
                deque.push(node);
//                node
            }


        }



    }



    class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    };

}
